import axios from 'axios';
import { Message } from 'element-ui';
const service = axios.create({
  // baseURL: process.env.VUE_APP_BASE_API, // url = base url + request url
  baseURL: '/prod-api', // url = base url + request url
  timeout: 100000 // request timeout
});
service.interceptors.request.use(
  (config) => {
    // if (true) {
    //   config.headers['Authorization'] = 'Bearer ' + token
    //   config.headers['Accept-Language'] = i18n.locale
    // }
    return config;
  },
  (error) => {
    return Promise.reject(error);
  }
);
service.interceptors.response.use(
  (response) => {
    const { code } = response.data;
    if (code === 401) {
      Message('无权访问，请重新登录！');
    }
    return response.data;
  },
  (error) => {
    return Promise.reject(error);
  }
);
export default service;
